<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .img-show{
            width: 300px;
            height: 300px;
        }
        .foot-img{
            width: 290px;
            padding:5px;
            margin-top: 5px;
            background-color: #ccc;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .foot-img-show{
            width:60px;
            height:60px;
        }
        .foot-img-show:hover{
           box-shadow: 0px 0px 5px red;
        }
            
    </style>
</head>
<body>
    <div class="img-navBox"></div>

    <div class="foot-img"></div>

    <script>
        let arr = [
            {id:1,imgUrl:'./img/1.gif'},
            {id:2,imgUrl:'./img/2.gif'},
            {id:3,imgUrl:'./img/3.gif'},
            {id:4,imgUrl:'./img/4.gif'}
        ]

        // 初始化展示第一张图
        let img_navBox = document.getElementsByClassName('img-navBox')[0]
        let img_show = document.createElement('img')
        img_show.src = arr[0].imgUrl
        img_show.className = 'img-show'
        img_navBox.appendChild(img_show)
  
        // 底部的图片排列
        let foot_img = document.getElementsByClassName('foot-img')[0]
        arr.forEach(el=>{
            // 创建div 和 img
            let divDOM = document.createElement('div')
            let imgDOM = document.createElement('img')
            // 添加图片路径和类名
            imgDOM.src = el.imgUrl
            imgDOM.className = 'foot-img-show'
            // 添加移入事件
            divDOM.addEventListener('mouseenter',()=>{
                img_show.src = el.imgUrl
            })
            // div添加图片
            divDOM.appendChild(imgDOM)
            // 底部添加div
            foot_img.appendChild(divDOM)
        })

     
    </script>
</body>
</html>